#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <set>
#include <vector>
#include <cstdio>
#include <cmath>
#define LL long long
#define nextLine() {int c = 0; while ((c = getchar()) != EOF && c != 10);}
#define sqr(a) ((a) * (a))
#define fill(a, c) memset(a, c, sizeof a)
#define ldb long double
#define sgn(a) ((a) > eps ? 1 : -1)
const ldb eps = 1e-9;
const ldb pi = fabs(atan2(0.0, -1.0));
const int INF = 1 << 28;
const LL LINF = 1ll << 50;
const ldb LDINF = 1e70;
const ldb cos3 = cos(pi / 3);
const ldb sin3 = sin(pi / 3);
using namespace std;

int n;
int a[100010];

void Load()
{
	cin >> n;
	int i;
	for (i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
}

void Solve()
{
	int i;
	LL res = 0;
	LL cnt = 0;
	for (i = 0; i < n; i++)
	{
		if (i > 0 && a[i] != a[i - 1])
		{
			res += (LL)cnt * ((LL)cnt - 1) / 2 + (LL)cnt;
			cnt = 0;
		}
		cnt++;
	}
	res += (LL)cnt * ((LL)cnt - 1) / 2 + (LL)cnt;
	cout << res;

}

#define file "a"

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(file".in", "rt", stdin);
	freopen(file".out", "wt", stdout);
	#endif
	Load();
	Solve();
	return 0;
}